home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # Start/stop the cron daemon.
- #
- ### BEGIN INIT INFO
- # Provides: cron
- # Required-Start: $remote_fs $syslog $time
- # Required-Stop: $remote_fs $syslog $time
- # Default-Start: 2 3 4 5
- # Default-Stop: 1
- # Short-Description: Regular background program processing daemon
- # Description: cron is a standard UNIX program that runs user-specified
- # programs at periodic scheduled times. vixie cron adds a
- # number of features to the basic UNIX cron, including better
- # security and more powerful configuration options.
- ### END INIT INFO
-
-
- test -f /usr/sbin/cron || exit 0
-
- PIDFILE=/var/run/crond.pid
- # In some systems the pidfile might be (incorrectly) set to /etc
- # if this pidfile is present, use it instead.
- [ -e /etc/cron.pid ] && PIDFILE=/etc/crond.pid
- [ -r /etc/default/cron ] && . /etc/default/cron
-
- . /lib/lsb/init-functions
-
- # Read the system's locale and set cron's locale. This locale
- # will be inherited by cron (used to set charset of emails)
- # and tasks running under it.
-
- parse_environment ()
- {
- ENV_FILE="none"
- [ -r /etc/environment ] && ENV_FILE="/etc/environment"
- [ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
- [ $ENV_FILE = none ] && return
-
- for var in LANG LC_ALL LC_CTYPE; do
- value=$(egrep "^[^#]*${var}=" $ENV_FILE | tail -n1 | cut -d= -f2)
- eval $var=$value
- done
- }
-
- # Parse the system's environment
- if [ "$READ_ENV" = "yes" ] ; then
- export LANG LC_ALL LC_CTYPE
- parse_environment
- fi
-
-
- case "$1" in
- start) log_daemon_msg "Starting periodic command scheduler" "crond"
- start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
- log_end_msg $?
- ;;
- stop) log_daemon_msg "Stopping periodic command scheduler" "crond"
- start-stop-daemon --stop --quiet --pidfile $PIDFILE --name cron
- log_end_msg $?
- ;;
- restart) log_daemon_msg "Restarting periodic command scheduler" "crond"
- start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name cron
- start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
- log_end_msg $?
- ;;
- reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "crond"
- # cron reloads automatically
- log_end_msg 0
- ;;
- status)
- status_of_proc -p $PIDFILE /usr/sbin/cron cron && exit 0 || exit $?
- ;;
- *) log_action_msg "Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload|status}"
- exit 2
- ;;
- esac
- exit 0
-